//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    internal class DuotoneEffect : Effect
    {
        private ColorBase color1;

        private ColorBase color2;


        private DuotoneTransferMode xfr1;

        private DuotoneTransferMode xfr2;

        public ColorBase Color1
        {
            get { return color1; }
            set { color1 = value; }
        }

        public ColorBase Color2
        {
            get { return color2; }
            set { color2 = value; }
        }

        public DuotoneTransferMode Xfr1
        {
            get { return xfr1; }
            set { xfr1 = value; }
        }

        public DuotoneTransferMode Xfr2
        {
            get { return xfr2; }
            set { xfr2 = value; }
        }


        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("duotone"))
            {
                Xfr1 = c.GetOptionalEnum("xfr1", DuotoneTransferMode.lin);
                Xfr2 = c.GetOptionalEnum("xfr2", DuotoneTransferMode.invLin);
                c.PassAttributes();
                Color1 = ColorBase.ReadColor(c);
                Color2 = ColorBase.ReadColor(c);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("duotone"))
            {
                c.SetOptionalEnum("xfr1", Xfr1, DuotoneTransferMode.lin);
                c.SetOptionalEnum("xfr2", Xfr2, DuotoneTransferMode.invLin);
                c.WriteOptionalElement(Color1);
                c.WriteOptionalElement(Color2);
            }
        }
    }
}